#ifndef LOGGER_H
#define LOGGER_H

#include <iostream>
#include <string>
#include <chrono>
#include <iomanip>
#include <sstream>

class Logger {
public:
    enum class Level {
        DEBUG,
        INFO,
        WARN,
        ERROR
    };

    static void log(Level level, const std::string& message) {
        auto now = std::chrono::system_clock::now();
        auto time = std::chrono::system_clock::to_time_t(now);
        auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
            now.time_since_epoch()
        ) % 1000;

        std::stringstream ss;
        ss << std::put_time(std::localtime(&time), "%Y-%m-%d %H:%M:%S")
           << '.' << std::setfill('0') << std::setw(3) << ms.count()
           << " [" << getLevelString(level) << "] "
           << message << std::endl;

        std::cout << ss.str() << std::flush;
    }

    static void debug(const std::string& message) {
        log(Level::DEBUG, message);
    }

    static void info(const std::string& message) {
        log(Level::INFO, message);
    }

    static void warn(const std::string& message) {
        log(Level::WARN, message);
    }

    static void error(const std::string& message) {
        log(Level::ERROR, message);
    }

private:
    static std::string getLevelString(Level level) {
        switch (level) {
            case Level::DEBUG: return "DEBUG";
            case Level::INFO:  return "INFO ";
            case Level::WARN:  return "WARN ";
            case Level::ERROR: return "ERROR";
            default:          return "UNKNOWN";
        }
    }
};

#endif // LOGGER_H 